import {
  getRequest,
  postRequest,
  putRequest,
  deleteRequest,
  postRequestWithNoForm,
} from "@/libs/axios";

// 分页获取角色数据
export const getRoleList = (params) => {
  // return getRequest("/role", params);
  return getRequest("/role/allChildren", params);
};
// 获取全部权限数据
export const getAllPermissionList = (params) => {
  return getRequest("/menu/tree", params);
};
// 格局角色后去权限数据
export const getPermissionList = (params) => {
  return getRequest("/menu/treeJurisdiction", params);
};
// 添加角色
export const addRole = (params) => {
  return postRequest("/role", params);
};
// 编辑角色
export const editRole = (params) => {
  return putRequest(`/role/${params.roleId}`, params);
};
// 删除角色
export const deleteRole = (ids, params) => {
  return deleteRequest(`/role/${ids}`, params);
};
// 加载部门子级数据
export const loadDepartment = (id) => {
  return getRequest(`/department/${id}`);
};
// 查看某角色拥有的菜单
export const selectRoleMenu = (params) => {
  return getRequest(`/roleMenu/${params}`);
};
// 保存角色菜单
export const saveRoleMenu = (id, params) => {
  return postRequestWithNoForm(`/roleMenu/${id}`, params);
};
// 获取用户数据 多条件
export const getUserListData = (params) => {
  return getRequest("/user", params);
};
// 添加用户
export const addUser = (params) => {
  return postRequest("/user", params);
};
// 编辑用户
export const editOtherUser = (params) => {
  return putRequest("/user/admin/edit", params);
};
// 启用用户
export const enableUser = (id, params) => {
  return putRequest(`/user/enable/${id}`, params);
};
// 删除用户
export const deleteUser = (ids, params) => {
  return deleteRequest(`/user/${ids}`, params);
};
// 重置用户密码
export const resetPassword = (params) => {
  return postRequest(`/user/resetPassword/${params}"`);
};
